//
//  NSBundle+CurrentLanguage.m
//  CoolTennisBall
//
//  Created by CA on 16/4/13.
//  Copyright © 2016年 CoolLang. All rights reserved.
//

#import "NSBundle+CurrentLanguage.h"

@implementation NSBundle (CurrentLanguage)

+ (BOOL)currentLanguageIsChinese
{
    NSArray *languages = [NSLocale preferredLanguages];
    NSString *currentLanguage = [languages objectAtIndex:0];
    // fr-CN
    return [currentLanguage rangeOfString:@"zh-Hans"].location != NSNotFound;
}

+ (BOOL)isThisLanguages {
    if ([kCurrentLanguage hasPrefix:@"en"] || [kCurrentLanguage hasPrefix:@"zh-Hans"]) {
        return YES;
    }else {
        return NO;
    }
}

+ (YFLanguage)currentLangeuage {
    
    YFLanguage tmp = kLanguageEnglish;
    NSArray *languages = [NSLocale preferredLanguages];
    NSString *currentLanguage = [languages objectAtIndex:0];
    
    if ([currentLanguage rangeOfString:@"zh-Hans"].location != NSNotFound) {
        tmp = kLanguageChineseSimple;
    } else if ([currentLanguage rangeOfString:@"fr"].location != NSNotFound) {
        tmp = kLanguageFrennch;
    } else if ([currentLanguage rangeOfString:@"en"].location != NSNotFound || [currentLanguage rangeOfString:@"zh-Hant"].location != NSNotFound) {
        tmp = kLanguageEnglish;
    } else {
        tmp = kLanguageEnglish;
    }
    return tmp;
}

@end
